module ArticlesHelper
  def last_updated_at_column(record) 
    if record.last_updated_at.nil? 
      "" 
    else   
      record.last_updated_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
  def last_accessed_at_column(record)    
    if record.last_accessed_at.nil? 
      "" 
    else
      record.last_accessed_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  def published_at_column(record)    
    if record.published_at.nil? 
      "" 
    else
      record.published_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
    def created_at_column(record)    
    if record.created_at.nil? 
      "" 
    else
      record.created_at.strftime("%d/%m/%Y %H:%M:%S")
    end
  end
  
   def body_form_column(record, input_name)
	text_area :record, :body, :name  =>  input_name,:cols => 120, :rows => 30,  :style  =>  "height:auto;"
 end

  
  def body_column(record)
	 textilize(record.body)
	end  
	
  def synopsis_column(record)
	 textilize(record.synopsis)
	end 
	
		  def tag_form_column(record,input_name) 

		    options = Tag.find(:all,:conditions=>["tags.websitesinf_id = ?",params[:id]]).collect do |c| 
		      [ c.name, c.id ] 
		    end 
		    select :record, :tag, options, 
           {:include_blank => false}
     
  end		
   
		  def category_form_column(record,input_name) 

		    options = Category.find(:all,:conditions=>["categories.websitesinf_id = ?",params[:id]]).collect do |c| 
		      [ c.name, c.id ] 
		    end 
		    select :record, :category, options, 
           {:include_blank => false}

     
  end  
  		  def categoryt_form_column(record,input_name) 
          
		    options = Categoryt.find(:all,:conditions=>["categoryts.websitesinf_id = ?",params[:id]]).collect do |c| 
		      [ c.name, c.id ] 
		    end 
		    select :record, :categoryt, options, 
           {:include_blank => false}

     
  end
  
 def websitesinf_form_column(record,input_name) 

 		    select_tag input_name + '[:id][]', options_from_collection_for_select(
    Websitesinf.find(:all,:conditions=>['websitesinfs.id <> ?',3]).collect,
    "id", "name"), :multiple => true
    
  end 
	
  def user_published_by_form_column(record,input_name) 
  
		    options = Ualia.find(:all).collect do |c| 
		      [ c.name, c.name ] 
		    end 
		    select :record, :user_published_by, options, 
           {:include_blank => false}
    
  end  
end
